using Crux.Core.Websockets;
using Crux.Core.Websockets.Redis;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace System;
/// <summary>
/// WebSocketRedisSupportServiceCollectionExtensions
/// </summary>
public static class WebSocketRedisSupportServiceCollectionExtensions
{
    /// <summary>
    ///
    /// </summary>
    public static IServiceCollection AddRedisSupport<T>(this IServiceCollection services)
        where T : IRedisResolver

    {
        services.TryAddSingleton(typeof(WebSocketLifetimeManager<>), typeof(RedisLifetimeManager<>));
        services.TryAddSingleton(typeof(IRedisResolver), typeof(T));

        return services;
    }
}